package net.lab1024.sa.admin.module.crawler.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import net.lab1024.sa.admin.module.crawler.domain.form.ShopCopyHisQueryForm;
import net.lab1024.sa.admin.module.crawler.domain.form.ShopCopyTaskForm;
import net.lab1024.sa.admin.module.crawler.domain.vo.ShopCopyHisVO;
import net.lab1024.sa.admin.module.crawler.service.ShopCopyHisService;
import net.lab1024.sa.admin.module.crawler.service.ShopCopyTaskService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 复制记录 Controller
 *
 * @Author  w
 * @Date 2025-03-29 06:03:19
 * @Copyright  w
 */

@RestController
@Tag(name = "复制记录")
public class ShopCopyHisController {

    @Resource
    private ShopCopyHisService shopCopyHisService;

    @Autowired
    ShopCopyTaskService shopCopyTaskService;

    @Operation(summary = "获取最新复制记录 @author  w")
    @PostMapping("/shopCopyHis/getOneCopyHis")
    @SaCheckPermission("shop:query")
    public ResponseDTO<ShopCopyHisVO> getOneCopyHis(@RequestBody  ShopCopyHisQueryForm queryForm) {
        return ResponseDTO.ok(shopCopyHisService.getOneCopyHis(queryForm));
    }

    @Operation(summary = "获取最新复制记录 @author  w")
    @PostMapping("/shopCopyHis/submitTask")
    @SaCheckPermission("shop:query")
    public ResponseDTO<ShopCopyHisVO> submitTask(@RequestBody  ShopCopyTaskForm form) {
        shopCopyTaskService.copyFactory(form);
        return ResponseDTO.ok();
    }
}
